<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>M&oacute;dulo Administrador</title>
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>js/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/theme.css">
        <link rel="stylesheet" href="<?php echo base_url(); ?>js/font-awesome/css/font-awesome.css">

        <script src="<?php echo base_url(); ?>js/jquery-1.7.2.min.js" type="text/javascript"></script>

        <!-- Demo page code -->

        <style type="text/css">
            #line-chart {
                height:300px;
                width:800px;
                margin: 0px auto;
                margin-top: 1em;
            }
            .brand { font-family: georgia, serif; }
            .brand .first {
                color: #ccc;
                font-style: italic;
            }
            .brand .second {
                color: #fff;
                font-weight: bold;
            }
        </style>

    </head>

    <body class=""> 
        <div class="navbar">
            <div class="navbar-inner">
                <ul class="nav pull-right">

                    <li id="fat-menu" class="dropdown">
                        <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
                            <i class="icon-user"></i> Susana 
                            <i class="icon-caret-down"></i>
                        </a>

                        <ul class="dropdown-menu">
                            <li><a tabindex="-1" class="visible-phone" href="#">Settings</a></li>
                            <li class="divider visible-phone"></li>
                            <li><a tabindex="-1" href="sign-in.html">Logout</a></li>
                        </ul>
                    </li>

                </ul>
                <a class="brand" href="http://localhost/Modulo_Admin/AdminController"><span class="first">M&oacute;dulo</span> <span class="second">Administrador</span></a>
            </div>
        </div>

        <div class="sidebar-nav">
            <a href="#pacientes-menu" onclick="window.location = 'http://localhost/Modulo_Admin/AdminController';" class="nav-header" data-toggle="collapse"><i class="icon-dashboard"></i>Pacientes</a>
            <a href="#personal-menu" class="nav-header" data-toggle="collapse"><i class="icon-briefcase"></i>Personal <i class="icon-chevron-up"></i></a>
            <ul id="personal-menu" class="nav nav-list collapse">
                <li><a href="#" onclick="window.location = 'http://localhost/Modulo_Admin/AdminController/page/2';" >Doctores</a></li>
                <li><a href="#" onclick="window.location = 'http://localhost/Modulo_Admin/AdminController/page/4';" >Recepcionistas</a></li>
            </ul>
            <a href="#reportes-menu" onclick="window.location = 'http://localhost/Modulo_Admin/Reportes';" class="nav-header collapsed" data-toggle="collapse"><i class="icon-exclamation-sign"></i>Reportes </a>
            <a href="#configuracion-menu" class="nav-header" data-toggle="collapse"><i class="icon-legal"></i>Configuraciones <i class="icon-chevron-up"></i></a>
            <ul id="configuracion-menu" class="nav nav-list collapse">
                <li ><a href="#" onclick="window.location = '<?php echo base_url(); ?>AdminController/page/6';">Especialidades</a></li>
                <li ><a href="#" onclick="window.location = '<?php echo base_url(); ?>AdminController/page/7';">Parámetros</a></li>
            </ul>
        </div>

        <div class="content">
            <div class="header">
                <h1 class="page-title">Especialidades</h1>
            </div>
            <fieldset class="container-fluid">
                <legend>Buscador</legend>
                <form class="form-inline" method="post" action="<?php echo base_url(); ?>AdminController/searchSpecialties">
                    <table width="95%">
                        <tr>
                            <td>
                                <div style="text-align: center">
                                    <label for="name">Nombre: </label>
                                    <input class="input-xlarge" id="appendedInputButton" name="name" type="text">
                                </div>
                            </td>
                            <td>
                                <div style="float:right">
                                    <button class="btn" type="submit"><i class="icon-search"></i> Buscar</button>
                                    <button class="btn" type="button" onclick="window.location = '<?php echo base_url(); ?>AdminController/page/6';" ><i class="icon-eye-open"></i> Ver Todas</button>  
                                </div>
                            </td>
                        </tr>
                    </table>
                </form>
            </fieldset>
            <fieldset class="container-fluid">
                <div class="container-fluid">
                    <div class="row-fluid">
                        <div class="btn-toolbar">
                            <a href="#addSpecialtyModal" role="button" data-toggle="modal">
                                <button class="btn btn-primary" onclick=""><i class="icon-plus"></i> Agregar Especialidad</button>
                            </a>
                        </div>
                        <div class="well">
                            <table class="table">
                                <?php if ($specialties == null) { ?>
                                    <thead>
                                        <tr>
                                            <th> No se encontr&oacute; ningunna especialidad en la b&uacute;squeda. </th>
                                        </tr>
                                    </thead>
                                <?php } else { ?>
                                    <thead>
                                        <tr>
                                            <th> Especialidad</th>
                                            <th> Duración Promedio <br/>(minutos)</th>
                                            <th> Adicionales a Atender <br/>(por dia) </th>
                                            <th style="text-align: center"> Opciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach ($specialties as $sp) { ?>
                                            <tr>
                                                <?php if ($sp->activo == 1) { ?>
                                                    <td><?php echo $sp->nombre_especialidad; ?></td>
                                                    <td><?php echo $sp->minutos_cita; ?>:00</td>
                                                    <td><?php echo $sp->adicionales_dia; ?></td>
                                                    <td style="text-align: center">
                                                        <a href="#" onclick="show_specialty('<?php echo $sp->ID_ESPECIALIDAD; ?>');" role="button" data-toggle="modal" class="edit-modal"><i class="icon-pencil"></i></a>
                                                        <a href="#" onclick="delete_specialty('<?php echo $sp->ID_ESPECIALIDAD; ?>');" role="button" data-toggle="modal"><i class="icon-remove"></i></a>
                                                    </td>
                                                <?php } else { ?>
                                                    <td style="color: red"><?php echo $sp->nombre_especialidad; ?></td>
                                                    <td style="color: red"><?php echo $sp->minutos_cita; ?>:00</td>
                                                    <td style="color: red"><?php echo $sp->adicionales_dia; ?></td>
                                                    <td style="text-align: center">
                                                        <a href="#" onclick="activate_specialty('<?php echo $sp->ID_ESPECIALIDAD; ?>');" role="button" data-toggle="modal" class="edit-modal"><i class="icon-ok"></i></a>
                                                    </td>
                                                <?php } ?>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                <?php } ?> 
                            </table>
                        </div>
                    </div>
                </div>
            </fieldset> 
        </div>
        
        <div class="modal small hide fade" id="addSpecialtyModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px;margin-left:-400px;margin-top: -250px">
            <!-- Modal para eliminar la especialidad del Centro de Salud -->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                <h3 id="myModalLabel">Agregar Especilidad</h3>
            </div>
            <div class="modal-body" style="padding:15px;">
                <form id="form_add_specialty" action="<?php echo base_url(); ?>AdminController/addSpecialty" method="POST">
                    <table style="height: 40px;width: 100%">
                        <?php if ($specialtiesNotInClinic != null) { ?>
                            <tr>
                                <td style="width:350px">
                                    <label> Nueva Especialidad : </label> 
                                    <select name="specialtyId" class="select">
                                        <?php foreach ($specialtiesNotInClinic as $sp) { ?>
                                            <option value="<?php echo $sp->ID_ESPECIALIDAD; ?>"><?php echo $sp->nombre_especialidad; ?></option>
                                        <?php } ?>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>Duración Promedio (minutos): </label>
                                    <select name="specialtyTime" id="specialtyTime"class="select">
                                        <option value="10">10</option>
                                        <option value="12">12</option>
                                        <option value="15" selected >15</option>
                                        <option value="20">20</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>Adicionales a atender (dia): </label>
                                    <select name="specialtyAditional" id="specialtyAditional" class="select">
                                        <option value="1">1</option>
                                        <option value="2" selected>2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                    </select>
                                </td>
                            </tr>
                        <?php } else { ?>
                            <tr>
                                <th> No hay especialidad disponibles para agregar al sistema. </th>
                            </tr>
                        <?php } ?>
                    </table>
                </form>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-arrow-left"></i> Atrás</button>
                <?php if ($specialtiesNotInClinic != null) { ?>
                    <button class="btn btn-danger" data-dismiss="modal" onclick="$('#form_add_specialty').submit();"><i class="icon-save"></i> Agregar</button>
                <?php } ?>
            </div>
        </div>

        <div class="modal small hide fade" id="deleteSpecialtyModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <!-- Modal para eliminar la especialidad del Centro de Salud -->
        </div>

        <div class="modal small hide fade" id="activateSpecialtyModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <!-- Modal para volver a activar la especialidad del Centro de Salud -->
        </div>

        <div class="modal small hide fade" id="editSpecialtyModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px;margin-left:-400px;margin-top: -170px">
            <!-- Contenido cargado por AJAX para la edición de las especialidades -->
        </div>         

        <script src="<?php echo base_url(); ?>js/bootstrap/js/bootstrap.js"></script>
        <script type="text/javascript">
            $("[rel=tooltip]").tooltip();
            $(function() {
                $('.demo-cancel-click').click(function() {
                    return false;
                });
            });
        </script>
        <script>
            $("[rel=tooltip]").tooltip();
            function show_specialty(specialty_id)
            {
                $.ajax({
                    url: '<?php echo base_url(); ?>AdminController/getSpecialtyInfo',
                    global: false,
                    type: "POST",
                    async: false,
                    dataType: "Text",
                    data: {
                        specialty_id: specialty_id
                    },
                    success: function(response)
                    {
                        $("#editSpecialtyModal").html(response).modal("show");
                    }
                });
            }

            function delete_specialty(specialty_id) {
                $.ajax({
                    url: '<?php echo base_url(); ?>AdminController/showSpecialtyDeleteConf',
                    global: false,
                    type: "POST",
                    async: false,
                    dataType: "Text",
                    data: {
                        specialty_id: specialty_id
                    },
                    success: function(response)
                    {
                        $("#deleteSpecialtyModal").html(response).modal("show");
                    }
                });
            }

            function activate_specialty(specialty_id) {
                $.ajax({
                    url: '<?php echo base_url(); ?>AdminController/showSpecialtyActivConf',
                    global: false,
                    type: "POST",
                    async: false,
                    dataType: "Text",
                    data: {
                        specialty_id: specialty_id
                    },
                    success: function(response)
                    {
                        $("#activateSpecialtyModal").html(response).modal("show");
                    }
                });
            }


        </script>
    </body>
</html>